package com.sak.app.subfragment; import android.os.Bundle; import android.os.Handler; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.webkit.WebChromeClient; import android.webkit.WebSettings; import android.webkit.WebView; import com.sak.app.R; import com.sak.app.adapter.SimpleHeaderAdapter; import com.sak.ultilviewlib.UltimateRefreshView; import com.sak.ultilviewlib.interfaces.OnHeaderRefreshListener; /** * A simple {@link Fragment} subclass. * Activities that contain this fragment must implement the * create an instance of this fragment. */ public class WebViewFragment extends Fragment { private UltimateRefreshView mUltimateRefreshView; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment View view=inflater.inflate(R.layout.fragment_web_view, container, false); WebView mWebView= (WebView) view.findViewById(R.id.webview); WebSettings settings = mWebView.getSettings(); settings.setJavaScriptEnabled(true); mWebView.setWebChromeClient(new WebChromeClient()); mWebView.loadUrl("https://www.baidu.com"); mUltimateRefreshView = (UltimateRefreshView) view.findViewById(R.id.refreshView); mUltimateRefreshView.setBaseHeaderAdapter(new SimpleHeaderAdapter(getContext())); mUltimateRefreshView.setOnHeaderRefreshListener(new OnHeaderRefreshListener() { @Override public void onHeaderRefresh(UltimateRefreshView view) { new Handler().postDelayed(new Runnable() { @Override public void run() { mUltimateRefreshView.onHeaderRefreshComplete(); } },2000); } }); return view; } }